package com.xframe.xdal.core.model.es;

import com.xframe.xdal.core.model.ConditionValue;


public class QueryBuilderFactory {

    public static IQueryBuilder create(ConditionValue conditionValue){
        IQueryBuilder queryBuilder = null;
        switch (conditionValue.getOperators()){
            case NE:
            case EQ:
                queryBuilder = new TermQueryBuilder(conditionValue.getEsQueryBuildArgs());
                break;
            case NLIKE:
            case LIKE:
                queryBuilder = new MatchQueryBuilder(conditionValue.getEsQueryBuildArgs());
                break;
            case LT:
            case GE:
            case GT:
            case LE:
                queryBuilder = new RangeQuery(conditionValue.getEsQueryBuildArgs());
                break;
            case NIN:
            case IN:
                queryBuilder = new TermsQueryBuilder(conditionValue.getEsQueryBuildArgs());
                break;
        }
        return queryBuilder;
    }
}
